[Fix-18274] Fix client heartbeat not updated after database out of service for longer than session timeout time#18275
[Fix-18274] Fix client heartbeat not updated after database out of service for longer than session timeout time#18275qiong-zhou wants to merge 2 commits into
Conversation
After database out of service for longer than session timeout time, client heartbeat will never be updated
| JdbcRegistryClientHeartbeatDTO clone = jdbcRegistryClientHeartbeatDTO.clone(); | ||
| clone.setLastHeartbeatTime(now); | ||
| jdbcRegistryClientRepository.updateById(jdbcRegistryClientHeartbeatDTO); | ||
| jdbcRegistryClientRepository.upsert(jdbcRegistryClientHeartbeatDTO); |
There was a problem hiding this comment.
It's better don't use upsert here, if the client heartbeat has been removed, then we should shutdown, since the server might have been failovered by other server.
There was a problem hiding this comment.
If the client is not down. The connection to the database is unreachable within more than a session timeout time. When the database is available, the client will send the heartbeat with the same client ID.
You mean in this case, the client should generate an new client ID and insert a new client record?
There was a problem hiding this comment.
If the session times out and the heartbeat is removed, the server/client should stop rather than reinsert a heartbeat, because at this point other servers may have already detected that the heartbeat is down and initiated fault-tolerance procedures.
There was a problem hiding this comment.
A more recommended approach would be to throw an exception when
jdbcRegistryClientRepository.updateById(jdbcRegistryClientHeartbeatDTO);
fails, and make refreshClientsHeartbeat return directly when jdbcRegistryServerState == JdbcRegistryServerState.DISCONNECTED.
There was a problem hiding this comment.
So this client should be restarted manually to register it again?
There was a problem hiding this comment.
The client shouldn't restarted, it should shutdown
There was a problem hiding this comment.
Sorry, I'm confused. How to register this client again?
There was a problem hiding this comment.
When a session times out, indicating that the client has disconnected, a disconnection event must be triggered, and the service will automatically terminate without requiring re-registration.
After database out of service for longer than session timeout time, client heartbeat will never be updated
|



After database out of service for longer than session timeout time, client heartbeat will never be updated
Was this PR generated or assisted by AI?
NO
Purpose of the pull request
Fix client heartbeat not updated after database out of service for longer than session timeout time
Brief change log
Verify this pull request
This pull request is code cleanup without any test coverage.
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md